# Maintainer: Konstantin Podsvirov <konstantin@podsvirov.pro>

_realname=pivy
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=0.6.6
pkgrel=1
pkgdesc='Python bindings to Coin3D (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url='https://github.com/coin3d/pivy'
license=('BSD')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-soqt")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-swig"
             "${MINGW_PACKAGE_PREFIX}-cc"
             #"${MINGW_PACKAGE_PREFIX}-glu"
             "${MINGW_PACKAGE_PREFIX}-cmake")
source=("${_realname}-${pkgver}.tar.gz"::"${url}/archive/${pkgver}.tar.gz"
        "001-pivy-0.6.5-setup-py-msystem-env.patch")
sha256sums=('27204574d894cc12aba5df5251770f731f326a3e7de4499e06b5f5809cc5659e'
            '0a37cf9f25ed3b0aca4547b484f448c840cf6a4d1f604ceed7094f8970a9c5b5')

prepare() {
  cd "${srcdir}"
  rm -rf "python-build-${CARCH}" | true
  cp -r "${_realname}-${pkgver}" "python-build-${CARCH}" && cd "python-build-${CARCH}"

  patch -p1 -i "${srcdir}/001-pivy-0.6.5-setup-py-msystem-env.patch"
}

build() {
  msg "Python build for ${CARCH}"
  cd "${srcdir}/python-build-${CARCH}"

  GENERATOR="MSYS Makefiles" \
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}" -O1 --skip-build
  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}

# vim: ts=2 sw=2 et:
